package com.gdd.videos.common.common;

import java.io.Serializable;

/**
 * @author zhangh     
 * @version V1.0.0
 * @projectName parent
 * @title     GddResult   
 * @package    com.gdd.videos.common  
 * @date   2019/9/2 16:57  
 * @explain 自定义的响应数据类结构:
 *              200  表示成功
 *              500  表示错误,错误信息在msg字段中
 *              501  bean验证错误  不管多少个错误都已map形式返回
 *              502  拦截器拦截到token出错
 *              555  异常抛出信息
 */
public class GddResult implements Serializable {

    // 响应状态
    private Integer gddStatus;

    // 响应消息
    private String gddMsg;

    // 响应数据
    private Object gddData;

    public GddResult() {
    }


    public GddResult(Integer gddStatus, String gddMsg, Object gddData) {
        this.gddStatus = gddStatus;
        this.gddMsg = gddMsg;
        this.gddData = gddData;
    }

    public Integer getGddStatus() {
        return gddStatus;
    }

    public void setGddStatus(Integer gddStatus) {
        this.gddStatus = gddStatus;
    }

    public String getGddMsg() {
        return gddMsg;
    }

    public void setGddMsg(String gddMsg) {
        this.gddMsg = gddMsg;
    }

    public Object getGddData() {
        return gddData;
    }

    public void setGddData(Object gddData) {
        this.gddData = gddData;
    }

    /**
     * 成功时返回的响应信息
     * @return
     */
    public static GddResult ok(){
        GddResult gddResult = new GddResult();
        gddResult.setGddStatus(200);
        gddResult.setGddMsg("成功!");
        return gddResult;
    }

    /**
     * 成功时返回的响应信息
     * @return
     */
    public static GddResult ok(Object data){
        GddResult gddResult = new GddResult();
        gddResult.setGddData(data);
        gddResult.setGddStatus(200);
        gddResult.setGddMsg("成功!");
        return gddResult;
    }


    /**
     * 出现错误,返回错误信息
     * @return
     */
    public static GddResult errorMsg(String msg){
        GddResult gddResult = new GddResult();
        gddResult.setGddStatus(500);
        gddResult.setGddMsg(msg);
        return gddResult;
    }
}
